#!/bin/bash

prog_device=`lsusb | grep "03eb:2ffa"`
if [ -n "$prog_device" ]; then
	sudo dfu-programmer at90usb162 start
	sleep 2
fi

controller=`lsusb | grep "03eb:2044"`
if [ -z "$controller" ]; then
	echo "SIW_Controller not detected"
	exit 1
fi

terminal=`find /sys/devices/ -name "*ACM*" | awk '{print substr($0,length,1)}'`

if [ -n "$terminal" ]; then
	echo "/dev/ttyACM"$terminal
	exit 0
fi


